package org.ucas.kgraph.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.ucas.kgraph.entity.File;
import org.ucas.kgraph.entity.Schem;

import java.util.List;

@Repository
public interface FileDao extends JpaRepository<File,Long>{
	
	@Query("FROM File t WHERE t.parent_id=?1 AND t.account_id = ?2 AND t.type = ?3 AND t.state=?4")
	public List<File> findFileListByUser(Long parent_id,Long account_id,String type,String state);
	
	@Query("FROM File t WHERE t.account_id = ?1 AND t.type = ?2 AND t.state=?3")
	public List<File> findFileListAllByUser(Long account_id,String type,String state);
	
	@Query("FROM File t WHERE t.type = ?1 AND t.state=?2")
	public List<File> findFileListAll(String type, String state);
	
	@Query("FROM File t WHERE t.parent_id = ?1")
	public List<File> findFileListAllByParent(Long file_id);
	
	@Query("FROM File t WHERE t.parent_id = ?1 AND t.type = ?2 AND t.state=?3")
	public List<File> findFileListByParent(Long file_id, String type, String state);
	
	@Query("FROM File t WHERE t.parent_id = ?1 AND t.type = ?2 AND t.state=?3 AND t.name like %?4%")
	public List findFileListBySearch(Long file_id, String type, String state, String searchString);

}

